import { http } from "@/utils/http";

export type commonResult<T> = {
  code: number;
  msg: string;
  result: T;
};

export type infoType = {
	id?: number,
	parentId?: number,
	systematicName?: string,
	systematicDesc?: string,
	logo?: string,
  parentSystemName?: string,
  productIds?:number[],
}
export type infoTypeList = {
  data: infoType[];
  total: number;
};

const List = '/system/systematic/v2/systematics';
const Url = '/system/systematic/v2/systematic';
export const getList = (params?: object) => {
  return http.request<commonResult<any>>("get", List, {
    params
  });
};
export const getInfo = (params?: object) => {
  return http.request<commonResult<infoType>>("get", Url, {
    params
  });
};
export const addInfo = (data?: object) => {
  return http.request<commonResult<any>>("post", Url, {
    data
  });
};
export const editInfo = (data?: object) => {
  return http.request<commonResult<any>>("put", Url, {
    data
  });
};
export const deleteInfo = (data?: object) => {
  return http.request<commonResult<any>>("delete", Url, {
    data
  });
};

/** 1.4.6系统下拉框 */
export const getSystemSelectList = (params?: object) => {
  return http.request<commonResult<Array<any>>>("get", '/system/systematic/v2/sys', {
    params
  });
};

/** 2.5.2.3系统下拉框（选择单位下面拥有设备的系统） */
export const getSystemSelect = (params?: object) => {
  return http.request<commonResult<Array<any>>>("get", '/business/project/v2/sys', {
    params
  });
};